<?php

$pd=$_GET['pd'];
function getRandomString($len, $chars=null)
{
    if (is_null($chars)) {
        $chars = "A1BCD3EFGH6IJK6LMN8OPQR9STU2VWXYZ0123456789";
    }
    mt_srand(10000000*(double)microtime());
    for ($i = 0, $str = '', $lc = strlen($chars)-1; $i < $len; $i++) {
        $str .= $chars[mt_rand(0, $lc)];
    }
    return $str;
}

$num=getRandomString(32);

if($_SERVER['HTTP_CLIENT_IP']){
    $onlineip=$_SERVER['HTTP_CLIENT_IP'];
}elseif($_SERVER['HTTP_X_FORWARDED_FOR']){
    $onlineip=$_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
    $onlineip=$_SERVER['REMOTE_ADDR'];
}

$stbid=md5($onlineip);//这个是用IP作为设备码  固定的
//$stbid=md5($num);//这个是用随机字母数字作为设备码  随机的

//echo $stbid;

$ts=array(

    "cctv1hd"=>"7780104586873900361",
    "cctv1fhd"=>"5000000010000030810",
    "cctv2"=>"6712427732700951500",
    "cctv3"=>"4871512150101568971",
    "cctv3fhd"=>"5000000002000020548",
    "cctv4"=>"6529283685694841127",
    "cctv5fhd"=>"5000000010000016619",
    "cctv5hd"=>"5922040007130019836",
    "cctv6fhd"=>"5000000010000018433",
    "cctv6hd"=>"5919402815101985320",
    "cctv7"=>"7319070262144570132",
    "cctv8fhd"=>"5000000010000018377",
    "cctv8hd"=>"8845820895945979833",
    "cctv9"=>"5000000001000024017",
    "cctv10hd"=>"9092756522938817434",
    "cctv10fhd"=>"5000000010000016738",
    "cctv11"=>"5934529806195667858",
    "cctv12"=>"7353916194983371497",
    "cctv13"=>"5644425207501602420",
    "cctv14hd"=>"4698841642605267773",
    "cctv14fhd"=>"5000000010000023358",
    "cctv15"=>"6270544915670196140",
    "hnwsfhd"=>"5000000010000030452",
    "hnwshd"=>"8374060722965940334",
    "dfwsfhd"=>"5000000010000032246",
    "jswsfhd"=>"5000000010000018509",
    "zjwsfhd"=>"5000000010000017320",
    "zjwshd"=>"7751216754229369822",
    "bjwsfhd"=>"5000000010000011502",
    "hljwsfhd"=>"5000000010000031107",
    "hljwshd"=>"9186015289302635496",
    "gdwshd"=>"6933976477918927839",
    "gdwsfhd"=>"5000000010000030417",
    "szwsfhd"=>"5000000010000024026",
    "sdwsfhd"=>"5000000010000027763",
    "hubwsfhd"=>"5000000010000022140",
    "ahwshd"=>"8519359625922101359",
    "ahwsfhd"=>"5000000001000027288",
    "dfwshd"=>"6319317455932234634",
    "dnwshd"=>"6058511135162408190",
    "dnwsfhd"=>"5000000001000005829",
    "lnwshd"=>"5393821316758187099",
    "lnwsfhd"=>"5000000001000008940",
    "jxwshd"=>"4625292887079171688",
    "jxwsfhd"=>"5000000001000032154",
    "tjwshd"=>"4966692255080753870",
    "tjwsfhd"=>"5000000001000030788",
    "scws"=>"7490243799257182211",
    "shxw"=>"7487426726248458200",
    "shys"=>"4624908642496875994",
    "wxtyhd"=>"5000000010000017540",
    "shdsjhd"=>"6607701200248700905",
    "shdsjfhd"=>"5000000010000032212",
    "shdshd"=>"6789517052815334336",
    "shwyhd"=>"6032059665143203976",
    "shjshd"=>"7081356299464623208",
    "dycjhd"=>"6617141658685778844",
    "dycjhd2"=>"5000000010000027146",
    "shsshd"=>"8538616372715313491",
    "shssfhd"=>"5000000002000019634",
    "dsjchd"=>"5000000002000004412",
    "bst01"=>"5000000001000001116",
    "bst02"=>"5000000001000002898",
    "bst03"=>"5000000001000004876",
    "bst04"=>"5000000001000004953",
    "bst05"=>"5000000001000006777",
    "bst06"=>"5000000001000017342",
    "bst07"=>"5000000001000018009",
    "bst08"=>"5000000001000019233",
    "bst09"=>"5000000001000023256",
    "djsjhd"=>"5000000001000022620",
    "jsqchd"=>"5000000002000004828",
    "xkkt"=>"7253543213338128343",
    "fztd"=>"9001547084732463424",
    "dsjc"=>"6458566386506430130",
    "hxjc"=>"6550198305014687851",
    "hxjchd"=>"5000000002000009455",
    "jbtyhd"=>"5000000002000029972",
    "dmxchd"=>"5000000002000023636",
    "dmxc"=>"9072176337701960899",
    "yxfy"=>",6006066787099938055",
    "dfcj"=>"7061949425579508455",
    "jsqc"=>"6674152167754937164",
    "qcxj"=>"5379866194427087552",
    "gzws"=>"9201427986773758105",
    "jlws"=>"7365582553698000803",
    "cqws"=>"7530473587484726181",
    "gxws"=>"4676357582335641620",
    "henws"=>"7384596500152929578",
    "hanws"=>"6187345409661409786",
    "qhws"=>"7493614642381322513",
    "hebws"=>"9037187833113630344",
    "nmgws"=>"7331079758781182663",
    "sxws"=>"9149348477727203604",
    "xjws"=>"5648045890196605092",
    "ynws"=>"6779252864642956855",
    "btws"=>"8683210039696467587",
    "gsws"=>"4777644378750257549",
    "nxws"=>"7511214846664648726",
    "shxws"=>"9042434207492183547",
    "xmws"=>"5084893189220221988",
    "jykt"=>"8812606677069767341",
    "kkse"=>"7851974109718180595",
    "jjkt"=>"4739906347743456369",
    "xzws"=>"5381760837640571168",
    "xzws2"=>"5000000002000021549",
    "dfws"=>"6322338140530063287",
    "dfdy"=>"6656174342854977929",
    "cetv1"=>"7489076744391846994",
    "cetv1fhd"=>"5000000002000002652",

    "yxfyhd"=>"5000000002000027005",
    "jspdhd"=>"5000000001000021713",
    "shwyhd"=>"5000000010000030951",
    "xfc"=>"5000000010000004266",
    "qjs"=>"5000000010000006249",
    "mlyy"=>"5000000010000008656",
    "jspd"=>"5000000010000026105",
);





$routedx=array('61.139.103.234','113.17.170.151'); //电信线路随机
$dxip=$routedx[rand(0,1)];

$routeyd=array('183.224.35.12','183.203.26.13');//移动线路随机
$ydip=$routeyd[rand(0,1)];

$routedx1=array('101.75.248.85','113.17.170.151'); //电信联通线路
$dxip1=$routedx1[rand(0,1)];
/*
61.139.103.234//四川省南充市 电信
183.224.35.12//云南省baidu市 移动
183.203.26.13   //山西省太原市 移动
113.17.170.151 //广西壮族自治区南宁市 电信
*/


$ch=  curl_init("http://cache.ott.ystenlive.itv.cmvideo.cn/index.m3u8?stbId=".$stbid."&Contentid=".$ts[$pd]."&channel-id=bestzb&livemode=1");

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);

$info = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
curl_exec($ch);

$info = str_replace("http://","",$info);

//$live="http://".$dxip."/".$info;//电信线路
//$live="http://113.17.170.151/".$info;//电信线路101.75.248.85
//$live="http://".$ydip."/".$info;//移动线路
$live="http://".$dxip1."/".$info;//电信联通线路

echo $live;
//header('location:'.$live);


    ?>